package com.example.smartmedicalsystem.repository;

import com.example.smartmedicalsystem.entity.Department;
import com.example.smartmedicalsystem.entity.Doctor;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;

public interface DoctorRepository extends JpaRepository<Doctor, Long> {
    List<Doctor> findByNameContaining(String name);

    Optional<Doctor> findByUser_Username(String username);

    List<Doctor> findByDepartment(Department department);
    // 方法名：findByUser_Id（根据 User 的 id 查询 Doctor）
    Optional<Doctor> findByUser_Id(Long userId);
    @Query("SELECT DISTINCT d FROM Doctor d LEFT JOIN FETCH d.schedules")
    List<Doctor> findAllWithSchedules();

}